package com.hy.hongying.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hy.hongying.entity.Videolike;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface VideoLikeDao extends BaseMapper<Videolike> {
    /*
    查看作品点赞
     */
    @Select("SELECT COUNT(iid) FROM t_videolike WHERE iid=${iid} and flag=${flag}")
    int getResourcesNums(@Param("iid")Integer iid,@Param("flag")Integer flag);
    /*
        查看用户作品点赞
         */
    @Select("SELECT * FROM t_videolike WHERE iid=${iid} and flag=${flag} and uid=${uid}")
    List<Videolike> getResourcesUser(@Param("iid")Integer iid, @Param("flag")Integer flag, @Param("uid")Integer uid);
    /*
    删除用户的作评
     */
    @Delete("DELETE FROM t_videolike WHERE  uid=${uid} and iid=${iid} and flag=${flag}")
    int delResourcesUser(Videolike videolike);
}
